package com.example.userp.app.myapplication.RcycleView.DividerItem;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Rect;
import android.support.annotation.ColorRes;
import android.support.annotation.DimenRes;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.example.userp.app.myapplication.RcycleView.flexibledivider.FlexibleDividerDecoration;

/**
 * Describe:
 * Created by ysy on 2018/9/21.
 */
public abstract class BaseDivider extends RecyclerView.ItemDecoration {

    Context mContext;
    protected int mDividerColor = Color.GREEN;
    protected int mDividerStrokeWidth = 10;
    protected boolean isShowFirstDivider = false;
    protected boolean isShowLastDivider = false;
    protected boolean isShowRightDivider = false;
    protected boolean isShowLeftDivider = false;
    protected int mRightMargin = 0;
    protected int mLeftMargin = 0;

    public BaseDivider color(final int color) {
        mDividerColor = color;
        return this;
    }

    public BaseDivider colorResId(@ColorRes int colorId) {
        mDividerColor = mContext.getResources().getColor(colorId);
        return this;
    }

    public BaseDivider size(int size) {
        mDividerStrokeWidth = size;
        return this;
    }

    public BaseDivider sizeResId(@DimenRes int sizeId) {
        mDividerStrokeWidth = (int) mContext.getResources().getDimension(sizeId);
        return this;
    }

    public BaseDivider showLastDivider() {
        isShowLastDivider = true;
        return this;
    }

    public BaseDivider showFirstDivider() {
        isShowFirstDivider = true;
        return this;
    }

    /**
     * 仅对网格 有效
     *
     * @return
     */
    public BaseDivider showRightDivider() {
        isShowRightDivider = true;
        return this;
    }

    /**
     * 仅对网格 有效
     *
     * @return
     */
    public BaseDivider showLeftDivider() {
        isShowLeftDivider = true;
        return this;
    }

    /**
     * 仅对横向 有效
     *
     * @return
     */
    public BaseDivider MarginRightDivider(int size) {
        mRightMargin = size;
        return this;
    }

    /**
     * 仅对横向 有效
     *
     * @return
     */
    public BaseDivider MarginLeftDivider(int size) {
        mLeftMargin = size;
        return this;
    }

}
